package com.alan.weather.controller;

import com.alan.weather.common.responseResult.R;
import com.alan.weather.entity.Employee;
import com.alan.weather.service.EmployeeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author zhuku
 */
@RestController
@RequestMapping("/employee")
public class EmployeeController {
    @Resource
    private EmployeeService employeeService;
    //登录
    @PostMapping("/login")
    public R login(@RequestBody Employee employee, HttpServletRequest request){
        return employeeService.login(employee,request);
    }
    //登出
    @PostMapping("/logout")
    public R logout(HttpServletRequest request){
        request.getSession().removeAttribute("employee");
        return R.success("退出成功！");
    }

}
